package io.a.atomic;

import java.util.concurrent.atomic.AtomicInteger;

public class Sample1_AtomicInteger1 {
    static int b = 0;

    public static void main(String[] args) throws InterruptedException {


        AtomicInteger a = new AtomicInteger(0);
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 10000; i++) {
                a.incrementAndGet();
                b++;
            }
        });
        t1.start();


        Thread t2 = new Thread(() -> {
            for (int i = 0; i < 10000; i++) {
                a.incrementAndGet();
                b++;
            }
        });
        t2.start();


        Thread.sleep(1000);
        System.out.println("a=" + a);
        System.out.println("b=" + b);
    }

}

